#pragma once

#include "tm1640.h"
#include "sys.h"

/* 背光亮度 */
#define BACKLIGHT_LUMINANCE_OFF         TM1640_CMD_LIGHT_OFF     
#define BACKLIGHT_LUMINANCE_LEVEL1      TM1640_CMD_LIGHT_1_16       
#define BACKLIGHT_LUMINANCE_LEVEL2      TM1640_CMD_LIGHT_2_16        
#define BACKLIGHT_LUMINANCE_LEVEL3      TM1640_CMD_LIGHT_4_16        
#define BACKLIGHT_LUMINANCE_LEVEL4      TM1640_CMD_LIGHT_10_16        
#define BACKLIGHT_LUMINANCE_LEVEL5      TM1640_CMD_LIGHT_12_16        
#define BACKLIGHT_LUMINANCE_LEVEL6      TM1640_CMD_LIGHT_13_16        
#define BACKLIGHT_LUMINANCE_LEVEL7      TM1640_CMD_LIGHT_14_16        

#define ICON_BTN_POWER_ON()     (P24 = 1)
#define ICON_BTN_POWER_OFF()    (P24 = 0)
#define ICON_BTN_PAGE_ON()      (P25 = 1)
#define ICON_BTN_PAGE_OFF()     (P25 = 0)
#define ICON_BTN_OTHER_ON()     (P26 = 1)
#define ICON_BTN_OTHER_OFF()    (P26 = 0)

typedef struct
{
    u8 data0;
    u8 data1;
    u8 data2;
    u8 data3;
    u8 data4;
    u8 data5;
    u8 data6;
    u8 data7;
    u8 data8;
}LED_Display;

enum
{
    /* 状态栏 */
    ICON_STATUS_WIFI = 0,       //WIFI状态
    ICON_STATUS_LOCK,           //按键锁状态
    ICON_STATUS_ELECTRIC_VALVE, //电动阀状态
    ICON_STATUS_FLOOR_HEATING,  //地暖状态
    /* 工作模式 */
    ICON_MODE_FRESH_AIR,        //新风模式
    ICON_MODE_ECONOMIC,         //节能模式
    ICON_MODE_FLOOR_HEATING,    //地暖模式
    /* 空调模式 */
    ICON_MODE_COOLING,          //制冷模式
    ICON_MODE_HEATING,          //制热模式
    ICON_MODE_AIR_CIRCULATION,  //通风模式
    ICON_MODE_DEHUMIDIFICATION, //除湿模式
    /* 风速显示 */
    ICON_WIND_SPEED_AUTO,       //自动
    ICON_WIND_SPEED_LOW,        //低速
    ICON_WIND_SPEED_MEDIUM,     //中速
    ICON_WIND_SPEED_HIGH,       //高速
    /* 按键显示 */
    ICON_BTN_POWER,             //电源开关按键
    ICON_BTN_PAGE,              //页面按键
    ICON_BTN_OTHER,             //其他按键

    ICON_MAX_NUM,               //ICON总数
};

enum
{
    TUBE_ID_1 = 0,              //数码管1
    TUBE_ID_2,                  //数码管2
    TUBE_ID_3,                  //数码管3
};

enum
{
    TYPE_VALUE_DEC = 0,
    TYPE_VALUE_HEX,
    TYPE_VALUE_SWITCH,
    TYPE_VALUE_UNIT,
};


void display_init(void);
void display_func(void);
void display_clear(void);
void display_tubex(u8 tubex, u8 valueType, u8 value, u8 isPositive, u8 isOn);
void led_display(void);
void display_test(void);
